<script src="{{ getAssets }}js/amazeui.datatables.min.js?v={{ assets_version }}"></script>
<script src="{{ getAssets }}js/jquery.table2excel.min.js?v={{ assets_version }}"></script>
<script>
var queryParams = {};
var tables = $('#dataTables').DataTable({
    "sAjaxSource" : '{{ urlfor "BadreportController.ViewGoodsAll"}}'
    ,"bLengthChange": false
    ,"fnServerData" : function(sSource, aoData, fnCallback) {
        queryParams = checkQueryTableData(aoData);
        var form = $('.query-form').serializeArray();
        $.each(form, function(i, value){
            queryParams[value.name] = value.value;
        });
        $.post(sSource, JSON.stringify(queryParams),function(resp) {
            isLoading = true;
            fnCallback(resp);
        },'json')
    }
    ,columns: [
        {"bSortable": false, render:function(data, type, full, meta) {
             return full.Badreport.Number;
        }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Badreport.BadreportUser;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return timetransDate(full.Badreport.BadreportTime);
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Badreport.AuditingUser;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return timetransDate(full.Badreport.AuditingTime);
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Badreport.ExecuteUser;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Badreport.ExecuteTime > 0 ? timetransDate(full.Badreport.ExecuteTime) : '';
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return productGroupName(full.Inventory.Products);
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Snd.sph;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Snd.cyl;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Snd.add;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Snd.model;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Snd.color;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Snd.size;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Acceptance.lot_number;
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Acceptance.lot_number ? timetransDate(full.Inventory.Acceptance.lot_number) : '';
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.Inventory.Acceptance.expiry_date ? timetransDate(full.Inventory.Acceptance.expiry_date) : '';
            }}
        ,{"bSortable": false, render:function(data, type, full, meta) {
                return full.badreport_num;
            }}
    ]
    ,"aLengthMenu":[20, 50, 100, 200]
	,'bLengthChange': true
    ,"serverSide": true
    ,"bPaginate" : true
    ,"bFilter" : false	//是否启动过滤、搜索功能
    ,"bInfo" : true //是否显示页脚信息，DataTables插件左下角显示记录数
    ,"bProcessing" : true //DataTables载入数据时，是否显示‘进度’提示
});

$("#query-submit").bind("click", function () { //点击按钮 触发table重新请求服务器
    $("#dataTables").dataTable().fnDraw(false);
    return false;
});
var isLoading = false;
$('#download').bind("click", function(){
    if(isLoading) {
        $("#dataTables").table2excel({

            exclude: ".noExl",

            name: "导出已报损商品明细",

            filename: "已报损商品明细",

            fileext: ".xls",

            exclude_img: false,

            exclude_links: false,

            exclude_inputs: false
        });
    } else {
        $("#searchsubmit").click();
        layer.msg("还没加载结束请耐心等待一下！");return false;
    }
    return false;
});

</script>
